package net.itzyz.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PhoneUtil {
	
	public static boolean isPhoneNumberValid(String phoneNumber){
		String expression = "^\\(?\\d{3}\\)?[- ]?(\\d{4})[- ]?(\\d{4})";
		String expression2 ="\\d{4}";
		Pattern pattern = Pattern.compile(expression);
		Matcher matcher = pattern.matcher(phoneNumber);
		Pattern pattern2 = Pattern.compile(expression2);
		Matcher matcher2 = pattern2.matcher(phoneNumber);
		return matcher.matches()?true:matcher2.matches();
	}
}
